<template>
  <div class="app-container">
    <Find :OriginalFilter="{ static: true }" :formList="formList" @findClicked="findClicked" />

    <!-- 数据列表 -->
    <el-card class="box-card mt10" :body-style="{ padding: '10px' }">
      <div slot="header" class="mb9 f16">
        <span style="font-weight: 600">出货明细资料</span>
      </div>
      <Table :tableHeader="tableHeader" :tableData="tableData" :TableHeight="100" :outTableHeight="75" stripe></Table>
      <!-- 分页器 -->
      <PageModule :PageData="{ total }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
    </el-card>
  </div>
</template>
<script lang="ts">
import { defineComponent, onMounted, watch } from 'vue'
import { reactive, ref } from 'vue'
import 'dayjs/locale/zh-cn'
import fileRequest from '@/utils/fileRequest'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'ShippingInformation'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import { TableList, selectList, type TableListType } from '@/plugins/mixin'
import Api from '@/api/GeneralManager/inquire/Shippinginformation'
const imgList = ref<string[]>([])

const formList = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '品牌',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入货号',
    inputValue: ''
  },
  {
    type: 'date',
    dateLabel: '客户交期',
    dateValue: ''
  },
  {
    type: 'date',
    dateLabel: '出货日期',
    dateValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '清空'
  }
  // {
  //   type: 'button',
  //   checkboxLabel: '导出'
  // }
])
const tableHeader = ref([
  {
    label: '出货单号',
    prop: 'shipSlipNo'
  },
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '品牌',
    prop: 'brand'
  },
  {
    label: '货号',
    prop: 'style'
  },
  {
    label: '颜色',
    prop: 'color'
  },
  {
    label: '样品类型',
    prop: 'sampleType'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '订单数量',
    prop: 'orderQty'
  },
  {
    label: '客户交期',
    prop: 'deliveryDate'
  },
  {
    label: '出货数量',
    prop: 'prodQty'
  },
  {
    label: '扫描时间 / 出货时间',
    prop: 'prodTime'
  },
  {
    label: '采集员',
    prop: 'prodUserName'
  },
  {
    type: 'img',
    label: '图片',
    fixed: true,
    prop: 'photoPath',
    srcList: imgList
  }
])
// 表格数据
const tableData = ref([])
// 分页器
const currentPage = ref(1)
const pageSize = ref(40)
const total = ref(658)

const handleSizeChange = (val: number) => {
  pageSize.value = val
  getTableList()
}
const handleCurrentChange = (val: number) => {
  currentPage.value = val
  getTableList()
}
const getTableList = async () => {
  let { Data, dataList, srcList } = (await TableList(formList, Api.getTableList2, currentPage.value, pageSize.value)) as TableListType
  tableData.value = dataList
  total.value = Data.total
  imgList.value = srcList
}
const getSelectList = async () => {
  await selectList(formList, Api.getSelectList)
}
onMounted(async () => {
  getTableList()
  getSelectList()
})

const findClicked = async (content: string) => {
  if (content === '置空') {
    formList.value.forEach((item) => {
      item.inputValue = ''
      item.selectValue = ''
      item.dateValue = ''
    })
    getTableList()
  }
  if (content === '导出') {
  }
}

watch(
  () =>
    formList.value.map((item: any) => {
      item.selectValue, item.inputValue, item.dateValue, item.checked
    }),
  () => {
    getTableList()
  }
)
</script>

<style lang="less" scoped>
.OrderSummaryContainer {
  height: 100%;

  // 筛选查询行
  .search {
    height: 20px;
    line-height: 20px;
    display: flex;
    align-items: center;

    .searchImg {
      width: 20px;
      height: 20px;
    }

    .searchText {
      font-size: 14px;
      font-family: PingFangSC-Medium-, PingFangSC-Medium;
      color: #666666;
      margin-left: 8px;
    }
  }

  // 搜索行
  .form {
    margin-top: 10px;

    .el-form {
      display: flex;
      justify-content: start;
      flex-wrap: wrap;
      height: 32px;
    }

    .inputBase {
      width: 128px;
      height: 32px;
    }

    :deep(.el-range__icon) {
      position: absolute;
      right: 6px;
      color: #f89027 !important;
    }

    :deep(.el-range__close-icon) {
      position: absolute;
      left: 5px;
    }

    .date {
      width: 320px;
    }

    .el-form-item:last-child {
      margin-right: 0;
    }

    .el-form-item {
      margin-right: 19px;

      .w-50 {
        width: 180px;
      }
    }

    .el-range__icon {
      display: none;
    }

    :deep(.el-range-input) {
      width: 110px;
    }

    :deep(.el-range-editor.el-input__wrapper) {
      padding: 0;
      padding-right: 10px;
    }

    :deep(.el-input__inner) {
      text-align: center;
    }
  }

  // 单选行
  .checkbox {
    display: flex;
    justify-content: right;
    height: 65px;
    align-items: center;
    margin-top: -50px;
    margin-bottom: 50px;

    .el-checkbox {
      margin-right: 15px;
    }

    :deep(.el-checkbox__input.is-checked + .el-checkbox__label) {
      color: black;
    }
  }

  // 卡片头部
  :deep(.el-card__header) {
    border-bottom: none;
    padding-bottom: 0;
    font-family: Segoe UI-Semibold, Segoe UI;
    font-weight: 600;
    font-size: 20px;
  }

  :deep(.el-card__body) {
    padding-top: 10px;
  }

  // 表格
  .table {
    padding-top: 6px;

    :deep(.cell) {
      text-align: center;
    }

    :deep(.el-table__inner-wrapper) {
      color: #191919;
    }

    // 表头改变颜色
    :deep(.el-table th.el-table__cell) {
      background: #f6f6f6;
      color: #191919;
    }

    // 斑马条纹颜色
    :deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
      background: #f6f6f6;
    }

    /* 非斑马纹颜色 */
    :deep(.el-table tr) {
      background: #fff5eb;
    }
  }

  // 底部
  .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;

    .total {
      font-size: 14px;
      color: rgba(0, 0, 0, 0.6);
      font-family: PingFangSC-Regular-, PingFangSC-Regular;
    }

    :deep(.el-input__wrapper) {
      padding: 0;
    }

    :deep(.el-input__suffix) {
      transform: translateX(-9px);
    }

    :deep(.el-pagination .el-select .el-input) {
      width: 88px;
    }

    :deep(.number) {
      border: 1px solid #dcdcdc;
      margin-right: 8px;
      border-radius: 3px 3px 3px 3px;
    }

    :deep(.is-active.number) {
      background-color: #f89027 !important;
      color: white;
      border-radius: 3px 3px 3px 3px;
    }

    .save {
      color: black;
      border: 1px solid #e7e7e7;
      background: #e7e7e7;
    }
  }
}
</style>
